<?php
/**
 * User: Jerry
 * Date: 2017/6/2
 * Time: 14:32
 */

namespace SDXApi\Model;


use Think\Model;

/**
 * Class ArticleModel
 * @author Jerry
 * @package SDXApi\Model
 */
class ArticleModel extends Model
{
    /**
     * @var string
     */
    protected $tableName = 'article';

    /**
     * @author Jerry
     * @param int $catId
     * @return mixed
     */
    public function findArticleByCatId($catId = 0)
    {
        $where = array(
            'cat_id'    => $catId,
            'is_open'   => 1,
        );

        $field = 'article_id, cat_id, title, content, author, add_time, description';

        return $this->field($field)
            ->where($where)
            ->order('sort desc')
            ->select();
    }
}